package com.bill99.http;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONObject;
import com.bill99.http.util.HttpURLUtils;
import com.bill99.util.PageData;



/**
 * 获取车辆信息接口
 * @author    GuHeYu
 * @version   V1.00 2018年5月31日
 * @see       [相关类/方法]
 * @since     Weline V100R001
 */
public class GetTransportVehicleInfoHttp {
	/**
     * 日志
     */
    public static final Logger logger = Logger.getLogger(GetTransportVehicleInfoHttp.class);

    /**
     * describe: 公共接口类
     * creat_time: 2018年5月31日
     * param: [pd, json]
     * return: java.lang.String
     */
    public static JSONObject getTransportVehicleInfo(PageData pd, String json) throws  IOException {
        // 当前时间毫秒数
        long beginMills = System.currentTimeMillis();
        //开始
        if (logger.isInfoEnabled()) {
            logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo]start...===");
        }
        //打印接口传来的参数
        if (logger.isInfoEnabled() && pd != null) {
            logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo]| pd is :" + pd.toString() + "===");
        }
        
        //打印调用接口入参
        if (logger.isInfoEnabled()) {
            logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo]|interface_param:" + json + "===");
        }
        String url = pd.getPdKey("url");
        
        //连接-获取返回的信息
        String response = HttpURLUtils.postJson(url, json, null,
                    null, null, null, new PageData());
        
//        String response = "{'ExecLength': 40036,'ExecState': 'ExecSucceed','ExecResult':{'Other':'','TotalPageCount':1,'TotalRecordCount':1,'DataList':[{'PlateNumber':'沪LQ0700','EngineNumber':'1','CompanyName':'上海马陆环卫清洁服务发展有限公司','VIN':'ml2','VModel':'','VCarriageType':'方','VLength':0,'VWidth':0,'VHeight':0,'VContent':0,'VVolume':1.8,'RatedLoad':0,'RealLoad':0,'BuyDate':'1753/1/1','SelfCheckStartDate':'2016/10/20','SelfCheckEndDate':'2018/6/30','PFBZ':'','BType':'装修垃圾'}]}}";
//        String response = "{'ExecLength': 37880,'ExecState': 'ExecSucceed','ExecResult':[{'CompanyName':'上海治为实业有限公司','CompanyFullName':'上海治为实业有限公司','Clerk':'王帮贵','ClerkTel':'13370216518','RegisteDistrict':'崇明','RegisteAddress':'崇明县陈家镇前裕公路199号2幢531室','WorkDistrict':'崇明','WorkAddress':'崇明县城桥镇鳌山路621号 ','WorkTel':'69696879 ','WorkPost':'202150 ','ParkDistrict':'崇明','ParkAddress':'崇明县城桥镇鳌山路621号 ','LegalPerson':'陈云峰 ','LegalPersonTel':'13701863652 ','RegisteredCapital':0,'OrganizationCertCode':'91310230MA1JXL2739','VehicleCount':28,'DriverCount':22,'SceneCount':1,'BType':'工程渣土,拆房垃圾','AmphibiousType':'陆运','BidArea':'','BIList':[{'LName':'道路运输许可证编号','LSDate':'','LEDate':'','LicenseCode':''},{'LName':'建筑渣土经营性服务许可证编号','LSDate':'','LEDate':'','LicenseCode':''},{'LName':'工商执照登记号','LSDate':'','LEDate':'','LicenseCode':''}]}]}";
//        String response = "{'ExecLength': 9962,'ExecState':'ExecSucceed','ExecResult':{'Other':'','TotalPageCount':1,'TotalRecordCount':1,'DataList':[{'PrintSerial':'E1PT20171128002*02-011','ItemCompanyName':'昶江建筑工程(上海)有限公司','ItemName':'沪D77801','ValidStartDate':'2018-06-04 00:00:00','ValidEndDate':'2018-07-02 00:00:00','WorkSiteJSCompanyName':'上海凯旋门企业发展有限公司','WorkSiteItemName':'天安阳光广场东地块（地下室）项目','WorkSiteItemAddress':'莫干山路120号','DisposalAddress':'蕴藻南路1号','LitterAmount':5000,'WayList':'莫干山路-->昌化路-->长寿路-->天目西路-->共和新路-->场中路-->江杨南路-->蕴藻南路'},{'PrintSerial':'E1PT20171128002*02-012','ItemCompanyName':'昶江建筑工程(上海)有限公司','ItemName':'沪D77916','ValidStartDate':'2018-06-04 00:00:00','ValidEndDate':'2018-07-02 00:00:00','WorkSiteJSCompanyName':'上海凯旋门企业发展有限公司','WorkSiteItemName':'天安阳光广场东地块（地下室）项目','WorkSiteItemAddress':'莫干山路120号','DisposalAddress':'蕴藻南路1号','LitterAmount':5000,'WayList':'莫干山路-->昌化路-->长寿路-->天目西路-->共和新路-->场中路-->江杨南路-->蕴藻南路'}]}}";
        //打印调用接口入参
        JSONObject newObj = JSONObject.parseObject(response);
        
        /** 返回结果  */
    	if (logger.isInfoEnabled() && newObj != null) {
    		logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo()] respons is :"
    				+ "{ExecLength:" + newObj.getString("ExecLength") + ",ExecState:" + newObj.getString("ExecState")
    				+ ",ExecException:" + newObj.getString("ExecException")+"}");
    	}

        // 计算耗时
        String time = String.valueOf(System.currentTimeMillis()-beginMills);
        /** 打印调用接口入参  */
        if (logger.isInfoEnabled()) {
            logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo]|interface_time:" + time + "===");
        }
        /** 结束  */
        if (logger.isInfoEnabled()) {
            logger.info("===[GetTransportVehicleInfoHttp][getTransportVehicleInfo] end...===");
        }
        return newObj;
    }
    
    public static void main(String[] args) {
    	//,\"DataList\":[{\"PlateNumber\":\"沪LQ0700\",\"EngineNumber\":\"ml1\",\"CompanyName\":\"上海马陆环卫清洁服务发展有限公司\",\"VIN\":\"ml2\",\"VModel\":\"\",\"VCarriageType\":\"方\",\"VLength\":0,\"VWidth\":0,\"VHeight\":0,\"VContent\":0,\"VVolume\":1.8,\"RatedLoad\":0,\"RealLoad\":0,\"BuyDate\":\"1753/1/1\",\"SelfCheckStartDate\":\"2016/10/20\",\"SelfCheckEndDate\":\"2018/6/30\",\"PFBZ\":\"\",\"BType\":\"装修垃圾\"}]
//    	String response = "{'ExecLength': 40036,'ExecState': 'ExecSucceed','ExecResult':{'Other':'','TotalPageCount':327,'TotalRecordCount':6521,'DataList':[{'PlateNumber':'沪LQ0700','EngineNumber':'ml1','CompanyName':'上海马陆环卫清洁服务发展有限公司','VIN':'ml2','VModel':'','VCarriageType':'方','VLength':0,'VWidth':0,'VHeight':0,'VContent':0,'VVolume':1.8,'RatedLoad':0,'RealLoad':0,'BuyDate':'1753/1/1','SelfCheckStartDate':'2016/10/20','SelfCheckEndDate':'2018/6/30','PFBZ':'','BType':'装修垃圾'}]}}";
//    	String response = "{'ExecLength': 37880,'ExecState': 'ExecSucceed','ExecResult':[{'CompanyName':'上海治为实业有限公司','CompanyFullName':'上海治为实业有限公司','Clerk':'王帮贵','ClerkTel':'13370216518','RegisteDistrict':'崇明','RegisteAddress':'崇明县陈家镇前裕公路199号2幢531室','WorkDistrict':'崇明','WorkAddress':'崇明县城桥镇鳌山路621号 ','WorkTel':'69696879 ','WorkPost':'202150 ','ParkDistrict':'崇明','ParkAddress':'崇明县城桥镇鳌山路621号 ','LegalPerson':'陈云峰 ','LegalPersonTel':'13701863652 ','RegisteredCapital':0,'OrganizationCertCode':'91310230MA1JXL2739','VehicleCount':28,'DriverCount':22,'SceneCount':1,'BType':'工程渣土,拆房垃圾','AmphibiousType':'陆运','BidArea':'','BIList':[{'LName':'道路运输许可证编号','LSDate':'','LEDate':'','LicenseCode':''},{'LName':'建筑渣土经营性服务许可证编号','LSDate':'','LEDate':'','LicenseCode':''},{'LName':'工商执照登记号','LSDate':'','LEDate':'','LicenseCode':''}]}]}";
    	String response = "{'ExecLength': 9962,'ExecState':'ExecSucceed','ExecResult':{'Other':'','TotalPageCount':522,'TotalRecordCount':10437,'DataList':[{'PrintSerial':'E1PT20171128002*02-011','ItemCompanyName':'昶江建筑工程(上海)有限公司','ItemName':'沪D77801','ValidStartDate':'2018-06-04 00:00:00','ValidEndDate':'2018-07-02 00:00:00','WorkSiteJSCompanyName':'上海凯旋门企业发展有限公司','WorkSiteItemName':'天安阳光广场东地块（地下室）项目','WorkSiteItemAddress':'莫干山路120号','DisposalAddress':'蕴藻南路1号','LitterAmount':5000,'WayList':'莫干山路-->昌化路-->长寿路-->天目西路-->共和新路-->场中路-->江杨南路-->蕴藻南路'},{'PrintSerial':'E1PT20171128002*02-012','ItemCompanyName':'昶江建筑工程(上海)有限公司','ItemName':'沪D77916','ValidStartDate':'2018-06-04 00:00:00','ValidEndDate':'2018-07-02 00:00:00','WorkSiteJSCompanyName':'上海凯旋门企业发展有限公司','WorkSiteItemName':'天安阳光广场东地块（地下室）项目','WorkSiteItemAddress':'莫干山路120号','DisposalAddress':'蕴藻南路1号','LitterAmount':5000,'WayList':'莫干山路-->昌化路-->长寿路-->天目西路-->共和新路-->场中路-->江杨南路-->蕴藻南路'}]}}";
        //打印调用接口入参
        JSONObject newObj = JSONObject.parseObject(response);
        System.out.println(newObj);
	}
}
